package com.shenmazong.servertalkadmin.controller;

import com.shenmazong.servertalkadmin.service.TbTeacherService;
import com.shenmazong.utils.ResponseResult;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api(tags = "接口-教师管理微服务")
public class TeacherController {


    @Autowired
    private TbTeacherService tbTeacherService;
    /**
     * TODO addTeacherUser 增加教师
     * @return
     */

    @PostMapping(value = "/addTeacherUser")
    @ApiOperation(value = "添加教师信息", notes = "添加教师信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userName", value = "登录账号", dataType = "String", required=true),
            @ApiImplicitParam(name="nickName", value = "教师姓名", dataType = "String", required=true),
            @ApiImplicitParam(name="subjectId", value = "学科id", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="classPrice", value = "费用", dataType = "Long", required=true, example = "0"),
            @ApiImplicitParam(name="classFee", value = "课程费用", dataType = "Long", required=true, example = "0")
    })
    public ResponseResult addTeacherUser(@RequestParam("userName") String userName,
                                         @RequestParam("nickName") String nickName,
                                         @RequestParam("subjectId") Integer subjectId,
                                         @RequestParam("classPrice") Long classPrice,
                                         @RequestParam("classFee") Long classFee) {
        return tbTeacherService.addTeacherUser(userName, nickName, subjectId, classPrice, classFee);
    }

    /**
     * TODO delTeacherUser 删除教师
     * @return
     */
    @ApiOperation(value = "删除教师", notes = "删除教师信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="teacherId", value = "教师id", dataType = "int", required=true, example = "0")
    })
    @PostMapping(value = "/delTeacherUser")
    public ResponseResult delTeacherUser(@RequestParam("teacherId") Integer teacherId) {
        return tbTeacherService.delTeacherUser(teacherId);
    }

    /**
     * TODO 修改教师密码
     * @return
     */
    @ApiOperation(value = "修改教师密码", notes = "修改教师登录密码")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="teacherId", value = "教师id", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="passWord", value = "登录密码", dataType = "String", required=true)
    })
    @PostMapping(value = "/setTeacherPass")
    public ResponseResult setTeacherPass(@RequestParam("teacherId") Integer teacherId,
                                 @RequestParam("passWord") String passWord) {
        return tbTeacherService.setTeacherPass(teacherId, passWord);
    }

    /**
     * TODO 修改教师信息
     * @return
     */
    @PostMapping(value = "/setTeacherInfo")
    @ApiOperation(value = "修改教师信息", notes = "修改教师信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="teacherId", value = "教师id", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="nickName", value = "教师名称", dataType = "String", required=true),
            @ApiImplicitParam(name="subjectId", value = "学科id", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="classPrice", value = "费用", dataType = "Long", required=true, example = "0"),
            @ApiImplicitParam(name="classFee", value = "课程费用", dataType = "Long", required=true, example = "0")
    })
    public ResponseResult setTeacherInfo(
            @RequestParam("teacherId") Integer teacherId,
            @RequestParam("nickName") String nickName,
            @RequestParam("subjectId") Integer subjectId,
            @RequestParam("classPrice") Long classPrice,
            @RequestParam("classFee") Long classFee) {
        return tbTeacherService.setTeacherInfo(teacherId, nickName, subjectId, classPrice, classFee);
    }

    /**
     * TODO 教师登录
     * @return
     */
    @ApiOperation(value = "教师登录", notes = "教师登录")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userName", value = "登录账号", dataType = "String", required=true),
            @ApiImplicitParam(name="userPass", value = "登录密码", dataType = "String", required=true)
    })
    @PostMapping(value = "/doTeacherLogin")
    public ResponseResult doTeacherLogin(
            @RequestParam("userName") String userName,
            @RequestParam("userPass") String userPass) {
        return tbTeacherService.doTeacherLogin(userName, userPass);
    }

    @ApiOperation(value = "获取教师信息", notes = "获取教师信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="teacherId", value = "教师id", dataType = "int", required=true, example = "0")
    })
    @PostMapping(value = "/getTeacherInfo")
    public ResponseResult getTeacherInfo(@RequestParam("teacherId") Integer teacherId) {
        return tbTeacherService.getTeacherInfo(teacherId);
    }

    @ApiOperation(value = "分页获取教师信息", notes = "分页获取教师信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="pageCurrent", value = "当前页", dataType = "int", required=true, example = "1"),
            @ApiImplicitParam(name="pageSize", value = "每页记录数", dataType = "int", required=true, example = "10")
    })
    @PostMapping(value = "/getTeacherByPage")
    public ResponseResult getTeacherByPage(Integer pageCurrent, Integer pageSize) {
        return tbTeacherService.getTeacherByPage(pageCurrent, pageSize);
    }
}
